svm: Avoid VMSAVE/VMLOAD/VMSAVE/VMLOAD sequence on every vmexit/vmentry.
authorKeir Fraser <keir@xensource.com>
Sat, 12 May 2007 18:04:35 +0000 (19:04 +0100)
committerKeir Fraser <keir@xensource.com>
Sat, 12 May 2007 18:04:35 +0000 (19:04 +0100)
commitf64b7618e11930c5402b02a85db112b72a2beb2b
tree59008421cbde97baed35bd824422ff0849387788
parent8665aa44c30b96457828d310f0140cd0987d78f1
svm: Avoid VMSAVE/VMLOAD/VMSAVE/VMLOAD sequence on every vmexit/vmentry.

Instead do this only on context switches. In cases where we need
access to state that is only saved to the VMCB on VMSAVE, we track
whether the state is in sync via a per-vcpu flag and VMSAVE on demand.

The context switch code can be further improved:
 1. No need to VMLOAD host state if we are switching to another SVM  VCPU.
 2. No need to VMSAVE host state at all (except once at start of day)
 because the registers that are saved do not change (or at least, none
 of the ones that matter change).

The performance is improvement is about 650 cycles for a null
hypercall. This reduces the total null-hypercall time for a non-debug
build of Xen down to around 3300 cycles on my AMD X2 system.

Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/hvm/svm/x86_32/exits.S
xen/arch/x86/hvm/svm/x86_64/exits.S
xen/arch/x86/smpboot.c
xen/arch/x86/traps.c
xen/arch/x86/x86_32/asm-offsets.c
xen/arch/x86/x86_32/traps.c
xen/arch/x86/x86_64/asm-offsets.c
xen/include/asm-x86/hvm/svm/svm.h
xen/include/asm-x86/hvm/svm/vmcb.h